Returns a shallow clone of this object
Syntax
Example
Library/Library.Test/TestReadOnlyList.cs
C# | Copy Code |
---|
List<string> strings = new List<string>(new string[] { "a", "b", "c" });
ReadOnlyList<String> read = new ReadOnlyList<string>(strings, false);
Assert.AreEqual(3, read.Count);
strings.RemoveAt(2);
Assert.AreEqual(2, read.Count);
Assert.AreEqual("a", read[0]);
Assert.AreEqual("b", read[1]);
Assert.AreEqual("a,b", String.Join(",", read.Clone().ToArray())); |
VB.NET | Copy Code |
---|
Dim strings As New List(Of String)(New String() {"a", "b", "c"})
Dim read As ReadOnlyList(Of [String]) = New ReadOnlyList(Of String)(strings, False)
Assert.AreEqual(3, read.Count)
strings.RemoveAt(2)
Assert.AreEqual(2, read.Count)
Assert.AreEqual("a", read(0))
Assert.AreEqual("b", read(1))
Assert.AreEqual("a,b", [String].Join(",", read.Clone().ToArray())) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also